<?php
defined('_JEXEC') or die;
?>

<script>
jQuery(document).ready(function() {
	jQuery('#mod_adminForm').searchtools(
		{
			"filtersHidden":false,
			"formSelector":"#mod_adminForm"
		}
	);
});
</script>


<form id="mod_adminForm" name="mod_adminForm" method="post" action="<?php echo JRoute::_('index.php?option=com_doska&view=messages');?>">
<div class="js-stools-container-filters">
<div class="js-stools-field-filter">
	<ul class="search-elems">
	
	<?php if($params->get('search_filter')) :?>
		<li><strong>Поиск:</strong><br>
			<input class="main-search js-stools-field-search" name="filter[search]" type="text" value="<?php echo $state->get('filter.search') ?>">
		</li>
	<?php endif;?>
	
	
	<?php if($params->get('category_filter')) :?>
		<li><strong>Категория:</strong><br>
			<select name="filter[category]">
				<option value="">Выберите категорию</option>
				<?php if(is_array($list_cat)) :?>
					<?php foreach($list_cat as $category) :?>
						<?php if($category['next']) :?>
							<optgroup label="<?php echo $category[0];?>">
			                    <?php foreach($category['next'] as $next) :?>
									<?php if($state->get('filter.category') == $next['id']) :?>
									<option selected="selected" value="<?php echo $next['id'];?>">--<?php echo $next['name'];?></option>
									<?php else :?>
									<option value="<?php echo $next['id'];?>">--<?php echo $next['name'];?></option>
									<?php endif;?>
								<?php endforeach;?>
		                  	</optgroup>
						<?php endif;?>
					<?php endforeach;?>
				<?php endif;?>	
			</select>
		</li>	
	<?php endif;?>
    
	<?php if($params->get('type_filter')) :?>
		<li><strong>Тип объявления:</strong><br>
		<select name="filter[type]">
			<option selected="selected" value="">Выберите тип</option>
	        <?php if(is_array($list_type)) :?>
				<?php foreach($list_type as $type) :?>
				<?php if($state->get('filter.type') == $type->id) :?>
									<option selected="selected" value="<?php echo $type->id;?>"><?php echo $type->name;?></option>
									<?php else :?>
									<option value="<?php echo $type->id;?>"><?php echo $type->name;?></option>
									<?php endif;?>
				<?php endforeach;?>
			<?php endif;?>	          
		</select>
		</li>
	<?php endif;?>   
	
    <?php if($params->get('price_filter')) :?>        
		<li><strong>Диапазон цен:</strong><br>
		
			От <input name="filter[price.min]" class="p_search js-stools-field-search" type="text" value="<?php echo $state->get('filter.price.min') ?>">	До <input name="filter[price.max]" class="p_search js-stools-field-search" type="text" value="<?php echo $state->get('filter.price.max') ?>">
		</li>
	<?php endif;?> 
        <input  name="list[limit]" type="hidden" value="<?php echo $state->get('list.limit') ?>">
        <input  name="task" type="hidden" value="filter">
		
	<li>
		<input value="Поиск" type="submit">
		<button class="js-stools-btn-clear" title="" type="button" data-original-title="Очистить"> Очистить </button>
	</li>
              
              
	</ul>
</div></div>
</form>
